﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using HA.ModFlow.Controls.PresentationClass.DataSetValue;
namespace HA.ModFlow.Controls.Windows.Grids
{
    /// <summary>
    /// winDSViewValue.xaml 的交互逻辑
    /// </summary>
    public partial class winDSViewValue : Window
    {
        public winDSViewValue(double [,,]data,string name,List <int [,]>ibound)
        {
            InitializeComponent();
            this.dtGrid.LoadingRow += new EventHandler<DataGridRowEventArgs>(dtGrid_LoadingRow);
            DataSetValueView dataset=new DataSetValueView ();
            this.dataSetValues = dataset.GetDataSetValueView(data,ibound);
            this.labDataSet.Text = "数据名称: "+name;
        }

        void dtGrid_LoadingRow(object sender, DataGridRowEventArgs e)
        {
            e.Row.Header = (e.Row.GetIndex() + 1).ToString();
        }
        private List<DataSetValueView> dataSetValues;
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.dtGrid.CanUserAddRows = false;
            this.dtGrid.CanUserReorderColumns = false;
            this.dtGrid.CanUserSortColumns = false;
            this.dtGrid.IsReadOnly = true;
            this.dtGrid.AutoGenerateColumns = false;

            DataGridTextColumn txt = new DataGridTextColumn();
            txt.Header = "层";
            Binding bin = new Binding("LayerIndex");
            txt.Binding = bin;
            this.dtGrid.Columns.Add(txt);

            txt = new DataGridTextColumn();
            txt.Header = "行";
            bin = new Binding("RowIndex");
            txt.Binding = bin;
            this.dtGrid.Columns.Add(txt);

            txt = new DataGridTextColumn();
            txt.Header = "列";
            bin = new Binding("ColIndex");
            txt.Binding = bin;
            this.dtGrid.Columns.Add(txt);

            txt = new DataGridTextColumn();
            txt.Header = "值";
            bin = new Binding("DataValue");
            txt.Binding = bin;
            this.dtGrid.Columns.Add(txt);

            txt = new DataGridTextColumn();
            txt.Header = "边界";
            bin = new Binding("Ibound");
            txt.IsReadOnly = true;
            txt.Binding = bin;
            this.dtGrid.Columns.Add(txt);
            this.dtGrid.ItemsSource = this.dataSetValues;
        }

        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
